*** Settings ***
Library           Selenium2Library
Library           Collections
Library           OperatingSystem
Library           String
Library           DateTime
*** Test Cases ***
F:\工作\中科院软件研究所\录制器\script\jstore1.lcl
    ${CLOSE_STATUS}    Set Variable    FALSE
    ${chrome_options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys
    Call Method    ${chrome_options}    set_capability    unhandledPromptBehavior    accept
    Call Method    ${chrome_options}    add_argument    --test-type --ignore-certificate-errors
    Create WebDriver    Chrome    chrome_options=${chrome_options}
    Maximize Browser Window
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第1行的-url-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_0
    Goto    http://39.104.118.163:8301/jpetstore/
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第2行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_1
    @{selectors}    Create List   xpath=//a[text()='Enter the Store']    css=p:nth-last-child(2) a    css=div#Content a    
    ${ret}=    获取定位器    ${selectors}
    click_method_2    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第3行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_3
    @{selectors}    Create List   css=a:nth-last-child(14) img    css=div#SidebarContent a:nth-last-child(14) > img    css=div#SidebarContent a:nth-child(1) > img    
    ${ret}=    获取定位器    ${selectors}
    click_method_4    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第4行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_5
    @{selectors}    Create List   xpath=//a[text()='FI-SW-01']    css=tr:nth-last-child(4) a    css=tr:nth-child(2) a    
    ${ret}=    获取定位器    ${selectors}
    click_method_6    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第5行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_7
    @{selector}    Create List    tr:nth-last-child(3) a.Button    tr:nth-child(2) a.Button    
    @{xpaths}    Create List   //a[text()='Add to Cart']['NOT_SURE']    
    ${ret}=    获取定位器ByModeOfAuto    ${selector}    ${xpaths}    10ms    7s
    click_method_8    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第6行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_9
    @{selectors}    Create List   xpath=//a[text()='Proceed to Checkout']    css=div#Cart a:nth-child(3)    
    ${ret}=    获取定位器    ${selectors}
    click_method_10    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第7行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_11
    @{selectors}    Create List   xpath=//input[@value='Login']    css=input[name='signon']    css=input[value='Login']    css=form:nth-last-child(2) input[name='signon']    css=div#Catalog input[name='signon']    
    ${ret}=    获取定位器    ${selectors}
    click_method_12    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第8行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_13
    @{selectors}    Create List   css=div#QuickLinks a:nth-last-child(1) > img    css=div#QuickLinks a:nth-child(9) > img    css=a:nth-child(9) img    
    ${ret}=    获取定位器    ${selectors}
    click_method_14    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第9行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_15
    @{selectors}    Create List   xpath=//a[text()='AV-CB-01']    css=tr:nth-last-child(2) a    css=tr:nth-child(2) a    
    ${ret}=    获取定位器    ${selectors}
    click_method_16    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第10行的-dblClick-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_17
    @{selector}    Create List    tr:nth-last-child(2) td:nth-last-child(1)    tr:nth-last-child(2) td:nth-child(5)    tr:nth-child(2) td:nth-last-child(1)    tr:nth-child(2) td:nth-child(5)    
    @{xpaths}    Create List   //td[text()='Add to Cart']['NOT_SURE']    
    ${ret}=    获取定位器ByModeOfAuto    ${selector}    ${xpaths}    10ms    7s
    dbclick_method_18    ${ret}
    #click ["//a[text()='Add to Cart']","a[class='Button']","tr:nth-last-child(2) a.Button","td:nth-child(5) a"] by [35.25,16.421875] <@npF03F>
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第12行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_19
    @{selectors}    Create List   css=a:nth-last-child(7) img    css=div#QuickLinks a:nth-last-child(7) > img    css=div#QuickLinks a:nth-child(3) > img    
    ${ret}=    获取定位器    ${selectors}
    click_method_20    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第13行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_21
    @{selectors}    Create List   xpath=//a[text()='K9-DL-01']    css=tr:nth-last-child(4) a    css=tr:nth-child(4) a    
    ${ret}=    获取定位器    ${selectors}
    click_method_22    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第14行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_23
    @{selector}    Create List    tr:nth-last-child(3) a.Button    tr:nth-child(2) a.Button    
    @{xpaths}    Create List   //a[text()='Add to Cart']['NOT_SURE']    
    ${ret}=    获取定位器ByModeOfAuto    ${selector}    ${xpaths}    10ms    7s
    click_method_24    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第15行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_25
    @{selectors}    Create List   css=div#QuickLinks a:nth-last-child(3) > img    css=div#QuickLinks a:nth-child(7) > img    css=a:nth-child(7) img    
    ${ret}=    获取定位器    ${selectors}
    click_method_26    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第16行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_27
    @{selectors}    Create List   xpath=//a[text()='FL-DLH-02']    css=tr:nth-last-child(1) a    css=tr:nth-child(3) a    
    ${ret}=    获取定位器    ${selectors}
    click_method_28    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第17行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_29
    @{selector}    Create List    tr:nth-last-child(2) a.Button    tr:nth-child(3) a.Button    
    @{xpaths}    Create List   //a[text()='Add to Cart']['NOT_SURE']    
    ${ret}=    获取定位器ByModeOfAuto    ${selector}    ${xpaths}    10ms    7s
    click_method_30    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第18行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_31
    @{selectors}    Create List   xpath=//a[text()='Return to Main Menu']    css=div#BackLink a    
    ${ret}=    获取定位器    ${selectors}
    click_method_32    ${ret}
    #------------------------------------------------------------------------------------------------------------------------------ 
    log to console    ------------------------执行文件:F:\工作\中科院软件研究所\录制器\script\jstore1.lcl--第19行的-click-命令--------------------------
    判断和等待页面加载完成
    switchFrame_method_33
    @{selectors}    Create List   css=map area:nth-last-child(1)    css=map area:nth-child(6)    
    ${ret}=    获取定位器    ${selectors}
    click_method_34    ${ret}
    ${CLOSE_STATUS}    Set Variable    TURE
    [Teardown]    Run Keyword If    '${CLOSE_STATUS}'=='FALSE'    错误用例截图
    ...    ELSE    Close Browser
*** Keywords ***
获取定位器
    [Arguments]    ${arg}
    [Timeout]    7s
    FOR    ${i}    IN RANGE    8
        ${arg}    Combine Lists    ${arg}    ${arg}
    END
    FOR    ${i}    IN    @{arg}
        sleep    10ms
        ${result}    ${returnvalue}    Run Keyword And Ignore Error    Wait Until Element Is Visible    ${i}    timeout=100ms
        Return From Keyword If    "${result}" == "PASS"    ${i}
    END
首要定位器
    [Arguments]    ${s}    ${timeout}
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Wait Until Element Is Visible    ${s}    timeout=${timeout}
    [Return]    ${result}
次要定位器
    [Arguments]    ${s}    ${timeout}
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Wait Until Element Is Visible    ${s}    timeout=${timeout}
    [Return]    ${result}
获取定位器ByModeOfPriorPass
    [Arguments]    ${arg}    ${prior_timeout}    ${delay}    ${timeout}
    [Timeout]    ${timeout}
    sleep    ${delay}
    ${num}    Set Variable    0
    FOR    ${i}    IN    @{arg}
        ${num}    Evaluate    ${num}+1
    END
    FOR    ${i}    IN RANGE    8
        ${arg}    Combine Lists    ${arg}    ${arg}
    END
    ${all}    Evaluate    0
    FOR    ${i}    IN    @{arg}
        ${yu}    Evaluate    ${all}%${num}
        ${result1}=    Run Keyword If    ${yu} == 0    首要定位器    ${i}    ${prior_timeout}
        ${result2}=    Run Keyword If    ${yu} != 0    次要定位器    ${i}    100ms
        Return From Keyword If    "${result1}" == "PASS" or "${result2}" == "PASS"    ${i}
        ${all}    Evaluate    ${all}+1
    END
获取定位器ByModeOfAuto
    [Arguments]    ${selector}    ${xpaths}    ${delay}    ${timeout}
    sleep    ${delay}
    ${ret}=    Wait Until Keyword Succeeds    ${timeout}    200ms    Execute JavaScript    function addNode(kvA,node){for(let index=0;index<kvA.length;index++){if(node.key==kvA[index].key){kvA[index].value=kvA[index].value+1;return}}kvArray.push(node)}let selectors=arguments[0];let xpaths=arguments[1];let kvArray=[];for(var i=0;i<selectors.length;i++){try{let nodes=document.querySelectorAll(selectors[i]);for(var j=0;j<nodes.length;j++){let node={key:nodes[j],value:1};addNode(kvArray,node)}}catch(e){continue}}for(var i=0;i<xpaths.length;i++){try{let nodePath=document.evaluate(xpaths[i],document);let element=nodePath.iterateNext();while(element!==null){let node={key:element,value:1};addNode(kvArray,node);element=nodePath.iterateNext()}}catch(e){continue}}function compare(property){return function(obj1,obj2){var value1=obj1[property];var value2=obj2[property];return value2-value1}}let resArray=kvArray.sort(compare("value"));return resArray[0].key;    ARGUMENTS    ${selector}    ${xpaths}
    [Return]    ${ret}
获取定位器ByModeOfPriorAuto
    [Arguments]    ${selector}    ${xpaths}    ${delay}    ${timeout}    ${prior_selector}
    sleep    ${delay}
    ${ret}=    Wait Until Keyword Succeeds    ${timeout}    200ms    Execute JavaScript    function addNode(kvA,node){for(let index=0;index<kvA.length;index++){if(node.key==kvA[index].key){kvA[index].value=kvA[index].value+1;return}}kvArray.push(node)}function hasNode(kvA,node){for(let index=0;index<kvA.length;index++){if(node.key==kvA[index].key){return true}}return false}let kvArray=[];let selectors=arguments[0];let xpaths=arguments[1];let prior_loca=arguments[2];prior_loca=""+prior_loca;let prior_kvArray=[];if(prior_loca.indexOf("//")==0){let prior_nodePath=document.evaluate(prior_loca,document);let prior_element=prior_nodePath.iterateNext();while(prior_element!=null){let node={key:prior_element,value:1};addNode(prior_kvArray,node);prior_element=prior_nodePath.iterateNext()}}else{let prior_nodes=document.querySelectorAll(prior_loca);for(var j=0;j<prior_nodes.length;j++){let node={key:prior_nodes[j],value:1};addNode(prior_kvArray,node)}}for(var i=0;i<selectors.length;i++){try{let nodes=document.querySelectorAll(selectors[i]);for(var j=0;j<nodes.length;j++){let node={key:nodes[j],value:1};if(!hasNode(prior_kvArray,node)){continue}addNode(kvArray,node)}}catch(e){continue}}for(var i=0;i<xpaths.length;i++){try{let nodePath=document.evaluate(xpaths[i],document);let element=nodePath.iterateNext();while(element!==null){let node={key:element,value:1};if(hasNode(prior_kvArray,node)){addNode(kvArray,node)}element=nodePath.iterateNext()}}catch(e){continue}}if(kvArray==[]){return prior_kvArray[0].key}function compare(property){return function(obj1,obj2){var value1=obj1[property];var value2=obj2[property];return value2-value1}}let resArray=kvArray.sort(compare("value"));return resArray[0].key;    ARGUMENTS    ${selector}    ${xpaths}    ${prior_selector}
    [Return]    ${ret}
判断和等待页面加载完成
    Wait For Condition    return document.readyState == 'complete'    60s
错误用例截图
    Run Keyword If Test Failed    Capture Page Screenshot    E:\\code_resp\\vscode\\myautotest\\myautotest\\extra\\executor\\robot\\test_project\\project\\pics\\jstore1.png
    Close Browser
switchFrame_method_0
    unselect frame    
switchFrame_method_1
    unselect frame    
click_method_2
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_2    ${ret}
switchFrame_method_3
    unselect frame    
click_method_4
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_4    ${ret}
switchFrame_method_5
    unselect frame    
click_method_6
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_6    ${ret}
switchFrame_method_7
    unselect frame    
click_method_8
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_8    ${ret}
switchFrame_method_9
    unselect frame    
click_method_10
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_10    ${ret}
switchFrame_method_11
    unselect frame    
click_method_12
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_12    ${ret}
switchFrame_method_13
    unselect frame    
click_method_14
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_14    ${ret}
switchFrame_method_15
    unselect frame    
click_method_16
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_16    ${ret}
switchFrame_method_17
    unselect frame    
dbclick_method_18
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Double Click Element    ${ret}
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    dbclick_method_18    ${ret}
switchFrame_method_19
    unselect frame    
click_method_20
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_20    ${ret}
switchFrame_method_21
    unselect frame    
click_method_22
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_22    ${ret}
switchFrame_method_23
    unselect frame    
click_method_24
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_24    ${ret}
switchFrame_method_25
    unselect frame    
click_method_26
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_26    ${ret}
switchFrame_method_27
    unselect frame    
click_method_28
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_28    ${ret}
switchFrame_method_29
    unselect frame    
click_method_30
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_30    ${ret}
switchFrame_method_31
    unselect frame    
click_method_32
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_32    ${ret}
switchFrame_method_33
    unselect frame    
click_method_34
    [Arguments]    ${ret}
    [Timeout]    7s
    sleep    10ms
    ${result}    ${returnvalue}    Run Keyword And Ignore Error    Click Element    ${ret}    
    Run keyword if    "${result}" == "FAIL"    sleep    500ms
    Run keyword if    "${result}" == "FAIL"    click_method_34    ${ret}
